package JavaSE.CODE.javaThread.WebDownload;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.net.URL;

public class WebDownloader extends Thread{

    private String url;
    private String name;

    public WebDownloader(String url, String name){
        this.url = url;
        this.name = name;
    }

    @Override
    public void run() {
        webDownload(url,name);
        System.out.println("over");
    }

    public void webDownload(String url, String name) {
        try {
            FileUtils.copyURLToFile(new URL(url),new File(name));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
